package com.review.study;

import java.util.*;

class ListOperation {

    public ListOperation() {
    }

    public ListOperation(NumberOperation numberOperation) {
        this.numberOperation = numberOperation;
    }

    public ListOperation(String name, NumberOperation numberOperation) {
        this.name = name;
        this.numberOperation = numberOperation;
    }

    private String name;

    private NumberOperation numberOperation;

    public NumberOperation getNumberOperation() {
        return numberOperation;
    }

    public void setNumberOperation(NumberOperation numberOperation) {
        this.numberOperation = numberOperation;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        ListOperation listOperation = new ListOperation();
        System.out.println(listOperation.getClass());
        listOperation.stackOperation();
        listOperation.ArrayListOperation();

    }

    public void stackOperation() {
        Stack stack = new Stack();
        Integer a = 10;
        int b = 11;
        int c = 12;
        int d = 13;
        stack.push(a);
        stack.push(b);
        stack.push(c);
        stack.push(d);
        System.out.println(stack.peek());
        System.out.println(stack.search(a));
        System.out.println(stack);
        while (!stack.isEmpty()) {
            System.out.println("出栈顺序" + stack.pop());
        }
        Enumeration enumeration = stack.elements();
        while (enumeration.hasMoreElements()) {
            System.out.println(enumeration.nextElement());
        }
    }

    public void ArrayListOperation() {
        //list的默认容量为10；
        List<String> list = new ArrayList<String>();
        //添加元素返回值为boolean类型
        list.add("1");
        list.add("2");
        list.add("3");
        System.out.println("list内容为" + list);
        //找出某个对象的下标。
        String a = "1";
        int i = list.indexOf(a);
        System.out.println("下标" + i);
        //list.contains(a)其实也调用了indexof（）方法。
        boolean b = list.contains(a);
        //移除某个对象
        boolean o = list.remove(a);
        //拿出list中的元素但是不移除。
        String string = list.get(0);
        System.out.println(string);
        //list的实际长度,拥有capacity属性的容器只有vector和string。
        int s = list.size();
        System.out.println("size" + s);
        //vector跟ArrayList基本相同，不过是Vector是线程安全的.
        //判断list是否为空；
        list.isEmpty();
        //遍历整个List
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
       String[]ss1= (String[]) list.toArray();
        for (int j = 0; j <ss1.length; j++) {
            System.out.println("转化为数组"+ss1[i]);
        }


    }
    public void LListOperation() {
        LinkedList linkedList=new LinkedList();

    }
}
